home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / jwpsrc.zip / ABOUT.C next >
C/C++ Source or Header  |  1993-03-31  |  3KB  |  105 lines

  1. /* Copyright (C) Stephen Chung, 1991-1993.  All rights reserved. */
  2.  
  3. #include "jwp.h"
  4. #include "idm.h"
  5.  
  6. #define GNUGPL     "GNUGPL.WRI"
  7.  
  8.  
  9. BOOL FAR PASCAL SimpleProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
  10. {
  11.     switch (message) {
  12.         case WM_INITDIALOG:
  13.             CenterDialogBox(hwnd);
  14.             return (TRUE);
  15.  
  16.         case WM_KEYDOWN:
  17.         case WM_CHAR:
  18.             switch (wParam) {
  19.                 case VK_ESCAPE: SendMessage(hwnd, WM_COMMAND, IDOK, 0L);
  20.                                 return (TRUE);
  21.             }
  22.             break;
  23.  
  24.         case WM_COMMAND:
  25.             switch (wParam) {
  26.                 case IDOK:
  27.                 case IDCANCEL:
  28.                     EndDialog(hwnd, FALSE);
  29.                     return (TRUE);
  30.             }
  31.             return (FALSE);
  32.     }
  33.  
  34.     return (FALSE);
  35. }
  36.  
  37.  
  38.  
  39. BOOL FAR PASCAL AboutProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
  40. {
  41.     switch (message) {
  42.         case WM_INITDIALOG:
  43.             CenterDialogBox(hwnd);
  44.             return (TRUE);
  45.  
  46.         case WM_COMMAND:
  47.             switch (wParam) {
  48.                 case 4201:      /* Disclaimers */
  49.                     DialogBox (hInstance, "Disclaimers", hwnd, SimpleProc);
  50.                     return (TRUE);
  51.  
  52.                 case 4202: {    /* Read GNU GPL */
  53.                     int len;
  54.                     OFSTRUCT of;
  55.                     char buffer[MAXLINELEN];
  56.  
  57.                     WinHelp(global.hwnd, global.help, HELP_CONTEXT, Topic_GNUGPL);
  58.                     return (0);
  59.  
  60.                     /* Find the GNU GPL file */
  61.                     if (OpenFile(GNUGPL, &of, OF_EXIST) < 0) goto HasError;
  62.                     if (_chmod(of.szPathName, 1, FA_RDONLY) == -1) {
  63.                         if (YesNo(hwnd, "Cannot open file '" GNUGPL "' as read-only.  Open "
  64.                                         "the file anyway?") != IDYES) return (TRUE);
  65.                     }
  66.  
  67.                     GetWindowsDirectory(buffer, MAXLINELEN);
  68.                     len = strlen(buffer);
  69.                     if (buffer[len-1] == '\\') buffer[len-1] = '\0';
  70.                     strcat(buffer, "\\WRITE " GNUGPL);
  71.  
  72.                     if (WinExec(buffer, SW_SHOW) < 32) goto HasError;
  73.                     return (TRUE);
  74.  
  75.                 HasError:
  76.                     ErrorMessage(hwnd, "Cannot execute Windows Write.  You should run Windows "
  77.                                           "Write yourself, and the load the file '" GNUGPL "' that "
  78.                                           "comes with this package.");
  79.                     return (TRUE);
  80.                 }
  81.  
  82.                 case 4203:      /* See Acknowledgements */
  83.                     DialogBox (hInstance, "Acknowledgements", hwnd, SimpleProc);
  84.                     return (TRUE);
  85.  
  86.                 case IDOK:
  87.                 case IDCANCEL:
  88.                     EndDialog(hwnd, FALSE);
  89.                     return (TRUE);
  90.             }
  91.             return (TRUE);
  92.  
  93.         case WM_KEYDOWN:
  94.         case WM_CHAR:
  95.             switch (wParam) {
  96.                 case VK_ESCAPE: SendMessage(hwnd, WM_COMMAND, IDOK, 0L);
  97.                                 return (TRUE);
  98.             }
  99.             break;
  100.  
  101.     }
  102.  
  103.     return (FALSE);
  104. }
  105.